package dto

import (
	"encoding/json"
	"fmt"
	"video_demo/entity"
)

type TopicFilterDTO struct {
	List       []entity.Topic `json:"list"`
	PageNum    int            `json:"pageNum"`
	PageSize   int            `json:"pageSize"`
	TotalPages int            `json:"totalPages"`
	TotalRows  int64          `json:"totalRows"`
}

type TopicInfo struct {
	ID       int               `json:"id"`
	Type     string            `json:"type"`
	Subject  string            `json:"subject"`
	Question string            `json:"question"`
	Options  map[string]string `json:"options"`
}

type AnswerInfo struct {
	ID     int    `json:"id"`
	Answer string `json:"answer"`
}

func ConvertToJSON(data interface{}) (string, error) {
	jsonData, err := json.MarshalIndent(data, "", "  ")
	if err != nil {
		return "", fmt.Errorf("JSON转换失败: %w", err)
	}
	return string(jsonData), nil
}

type TestPaperFilterDTO struct {
	List       []entity.TestPaper `json:"list"`
	PageNum    int                `json:"pageNum"`
	PageSize   int                `json:"pageSize"`
	TotalPages int                `json:"totalPages"`
	TotalRows  int64              `json:"totalRows"`
}
